<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>添加住院病人</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css">
  <script src="../../../bootstrap-3.3.7-dist/js/jquery-3.4.1.min.js"></script>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
          <tr>
            <td width="15"><img src="../../images/index_32.gif" width="9" height="9"></td>
            <td valign="bottom" class="title">添加住院病人</td>
          </tr>
      </table></td>
    </tr>
  </table>
  <form name="form1" method="post" action="">
<table width="95%"  border="0" cellpadding="0" cellspacing="0">


  <tr>
    <td width="90" align="center" class="td_form01">病人姓名</td>
    <td colspan="3" class="td_form02"><input name="pname" type="text" class="input"></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">性别</td>
    <td colspan="3" class="td_form02">
      <select name="pgender">
      <option value="男">男</option>
      <option value="女">女</option>
      </select>
    </td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">身份证号</td>
    <td colspan="3" class="td_form02"><input name="pcode" type="text" class="input"></td>
  </tr>

  <tr>
    <td width="90" align="center" class="td_form01">联系电话</td>
    <td colspan="3" class="td_form02"><input name="inpcontact" type="text" class="input"></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">科室</td>
    <td colspan="3" class="td_form02"> <select name="depid">

    </select></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">主治医生</td>
    <td colspan="3" class="td_form02"> <select name="staid">

    </select></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">病房</td>
    <td colspan="3" class="td_form02"> <select name="sckid">

    </select></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">押金</td>
    <td colspan="3" class="td_form02"><input name="inpdeposit" type="text" class="input"></td>
  </tr>
  <tr>
    <td width="90" align="center" class="td_form01">出院结论</td>
    <td colspan="3" class="td_form02"><input name="textfield" type="text" class="input"></td>
  </tr>

</table>
  <br>
  <table width="100%"  border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center"><input id="submit" type="button" class="buttonface" value="  增加  ">
        <input name="Submit" type="submit" class="buttonface" onClick="window.close()" value="  关闭  "></td>
    </tr>
  </table>
  </form>
</center>
<script language=JavaScript type=text/JavaScript>


         function f() {
             $.ajax({
                 url: "/feign/book/getdeparement",
                 type: "get",
                 dataType: "json",
               headers: {
                 Accept: "application/json; charset=utf-8",
                 Authorization: location.href.split("=")[1]
               },
                 success: function (data) {
                   $.each(data.data,function (index,data) {
                     $("select[name='depid']").append("<option value='" + data.data.depid + "'>" + data.data.depname + "</option>"),
                             fun1()
                   })

                 }
             })
         }


        function fun1() {
            $("select[name='depid']").change(function () {
                var depid = $("select[name='depid']").val();
                $.ajax({
                    url: "/feign/book/displayStaffByDepartment",
                    type: "get",
                    dataType: "json",
                  headers: {
                    Accept: "application/json; charset=utf-8",
                    Authorization: location.href.split("=")[1]
                  },
                    data: {"depid": depid,
                        "posid":1,
                    },
                    success: function (data) {
                      $.each(data.data,function (index,data) {
                        $("select[name='satid1']").append("<option value='" + data.data.staffid + "'>" + data.data.staname + "</option>")
                      })
                    }
                })
                $.ajax({
                    url: "/fegin/book/displayFullSckbed",
                    type: "get",
                    dataType: "json",
                  headers: {
                    Accept: "application/json; charset=utf-8",
                    Authorization: location.href.split("=")[1]
                  },
                    data: {"depid": depid

                    },
                    success: function (data) {
                      $.each(data.data,function (index,data) {
                        $("select[name='satid2']").append("<option value='" + data.data.sckid + "'>" + data.data.sckbedsid + "</option>")
                      })
                    }
                })
            })

            $("input[id='submit']").on("click",function () {
                $.ajax({
                    url:"/fegin/book/insertInpatientMessage",
                    type:"post",
                  headers: {
                    Accept: "application/json; charset=utf-8",
                    Authorization: location.href.split("=")[1]
                  },
                    data:$("form").serialize(),
                    dataType:"json",
                    success:function (data) {
                        alert(data.msg)
                        if (data.code==200){
                            alert(data.msg);
                        }
                    }
                })

            })
        }



</script>
</body>
</html>
